package main

import "fmt"

func main() {
	// 0 arg
	AddSum()
	// multi args
	fmt.Println(AddSum(1,2,3,4,5))
	//slice arg
	arr:=[]int{1,2,3,4,5}
	fmt.Println(AddSum(arr ...))

	//1
	sum,avg,count := getScore(90,78,87,65,55)
	fmt.Printf("学员共有%d门成绩，总成绩为%.2f,平均成绩为%.2f",count,sum,avg)

	//2
	scores := []float64{90,82,78.5,96,67,87,68}
	sum,avg,count = getScore(scores ...)
	fmt.Printf("学员共有%d门成绩，总成绩为%.2f,平均成绩为%.2f",count,sum,avg)

}

func AddSum(nums ...int)(sum int){
	fmt.Printf("%T \n",nums)  //[]int
	for _,value := range nums  {
		sum += value
	}
	return
}

func getScore(scores ...float64) (sum,avg float64,count int) {
	for _,value := range scores {
		sum += value
		count++
	}
	avg = sum/float64(count)
	return
}